#include "task_cycle.h"
#include "FreeRTOS.h"
#include "task.h"
#include "hek1008.h"
#include "hem_port.h"
#include "main.h"
#include "task_modbus.h"
#include "app_can.h"
#include "para.h"
#include "app_output.h"

#define TASK_PRIO_STACKSIZE_100ms 128
static TaskHandle_t task_100ms_handle = NULL;

void Task_100ms(void);

void Task_100ms_init(void)
{
    xTaskCreate((TaskFunction_t)Task_100ms,"100ms_task",TASK_PRIO_STACKSIZE_100ms,NULL,TASK_PRIO_100ms,(TaskHandle_t *)task_100ms_handle);
}
uint32_t ul_set_param_cnt = 0;
void set_param(void)
{
    if(uc_set_param_config_changed == 0) return;
    ul_set_param_cnt++;
    if(ul_set_param_cnt < 5) return;
    ul_set_param_cnt = 0;

    uc_set_param_config_changed = 0;

    hem_config_save(&g_config);//这个函数频繁调用会进入硬件错误中断，原因是flash写需要时间
}
void Task_100ms(void)
{
    while(1)
    {
        set_param();
        
		Main_pca9555_out();
        pwmi_parameter_store();
        Main_Reset();
        modbus_tcp_param_save();
        vTaskDelay(100);
    }
}

















